package com.demo.system;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;

/**
 * DemoList系统启动类
 *
 * @author demo
 * @since 1.0.0
 */
@SpringBootApplication
@EnableDiscoveryClient // 启用服务发现客户端
@Slf4j
public class DemoSystemApplication {

    /**
     * 应用程序入口方法
     *
     * @param args 命令行参数
     */
    public static void main(String[] args) {
        try {
            ApplicationContext context = SpringApplication.run(DemoSystemApplication.class, args);
            Environment env = context.getEnvironment();
            String port = env.getProperty("server.port");
            String appName = env.getProperty("spring.application.name");

            log.info("=================================================");
            log.info("DemoList系统 [{}] 启动成功！", appName);
            log.info("服务端口: {}", port);
            log.info("环境配置: {}", env.getActiveProfiles().length > 0 ?
                    String.join(",", env.getActiveProfiles()) : "default");
            log.info("=================================================");
        } catch (Exception e) {
            log.error("DemoList系统启动失败: {}", e.getMessage(), e);
            System.exit(1);
        }
    }
}
